#!/bin/sh
# sh cycle_change_partition_location.sh db tb location 20180701 20170801
DB=$1
TB=$2
LOCATION=$3
if [[ $# == 5 ]]; then
    begin_date=$4
    end_date=$5
    date=${begin_date}
    while [[ "${date}" -le "${end_date}" ]]
    do
      sql="use $DB;alter table ${TB} partition(data_date=${date}) set location '$LOCATION${date}'"
      echo ${sql}
      hive -e "${sql}"
      date=`date -d "$date 1 days" +"%Y%m%d"`
    done
else
    echo 'Parameter error!'
fi